const express = require("express");
const app = express();

const mw1 = function(req,res ,next){
    req.a = 'suliang';
    console.log('这是局部中间件！');
    next();
}

const mw2 = function(req,res,next){
    req.a = 'ming';
    console.log('这也是局部中间件');
    next();
}
app.get('/' , mw1 ,function(req,res){
    res.send(req.a + ' requested a get request!') //suliang requested a get request!
});

app.get('/user',mw2,function(req,res){
    res.send(req.a +' is not fund')  //undefined is not fund
})
app.listen(8081,function(){
    console.log('http://127.0.0.1:8081');
})